package com.qdl.rym.util;

import com.qdl.rym.base.ResultModel;

/**
 * @Description: Results
 * @Author: ChenXueLi
 * @Date: 2018-11-10 12:35
 */
public class ResultUtil {

    private ResultUtil() {}

    public static ResultModel newResultModel() {
        return new ResultModel();

    }

    public static ResultModel newResultModel(boolean success) {
        return new ResultModel(success);
    }


    /*业务调用成功*/

    public static ResultModel success() {
        return new ResultModel();
    }

    public static ResultModel success(String msg) {
        return new ResultModel(true, null, msg);
    }

    public static ResultModel success(Integer code, String msg) {
        return new ResultModel(true, code, msg);
    }

    public static ResultModel successWithStatus(Integer status) {
        return new ResultModel(true, status);
    }

    public static ResultModel successWithData(Object data) {
        return new ResultModel(true, null, null, data);
    }

    public static ResultModel successWithData(Object data, String msg) {
        return new ResultModel(true, null, msg, data);
    }

    public static ResultModel successWithData(Object data, Integer code, String msg) {
        return new ResultModel(true, code, msg, data);
    }

    /**
     * 业务调用失败
     * @return
     */
    public static ResultModel failure() {
        return new ResultModel(false);
    }

    public static ResultModel failure(String msg) {
        return new ResultModel(false, null, msg);
    }

    public static ResultModel failure(Integer code, String msg) {
        return new ResultModel(false, code, msg);
    }

    public static ResultModel failureWithStatus(Integer status) {
        return new ResultModel(false, status);
    }

    public static ResultModel failureWithData(Object data) {
        return new ResultModel(false, null, null, data);
    }

    public static ResultModel failureWithData(Object data, String msg) {
        return new ResultModel(false, null, msg, data);
    }

    public static ResultModel failureWithData(Object data, Integer code, String msg) {
        return new ResultModel(false, code, msg, data);
    }

}
